library(tibble)
library(ggplot2)

library(car)
# Panel Values####
df <- tibble::tibble(
  month_year = as.Date(c("2022-01-01", "2022-02-01", "2022-03-01", "2022-04-01", "2022-05-01", 
                         "2022-06-01", "2022-07-01", "2022-08-01", "2022-09-01", "2022-10-01",
                         "2022-11-01", "2022-12-01", "2023-01-01", "2023-02-01", "2023-03-01", "2023-04-01")),
  Y = c(83.648151, 84.365168, 85.009849, 85.124914, 84.941094, 
        84.902026, 85.067693, 85.459784, 87.319784, 87.412304, 
        86.365590, 85.120584, 84.282976, 84.579300, 84.761890, 83.962681),
  Time = 0:15,
  Intervention = c(rep(0, 10), rep(1, 6)), 
  TimeAfterIntervention = c(rep(0, 10), 0:5)
)
# ITS Model
its_model <- lm(Y ~ Time + Intervention + TimeAfterIntervention, data = df)
summary(its_model)
# Summary of the model
# Calculate VIF
vif_values <- vif(its_model)

# Display VIF values
print(vif_values)



###########Decahose Values


df2 <- tibble::tibble(
  month_year = as.Date(c("2022-01-01", "2022-02-01", "2022-03-01", "2022-04-01", "2022-05-01", 
                         "2022-06-01", "2022-07-01", "2022-08-01", "2022-09-01", "2022-10-01",
                         "2022-11-01", "2022-12-01", "2023-01-01", "2023-02-01", "2023-03-01", "2023-04-01")),
  Y = c(84.6309, 84.6327, 85.6863, 85.6369, 84.9082, 
        85.0195, 85.0075, 85.4599, 85.6809, 85.6093, 
        84.8489, 83.8767, 82.5608, 83.5648, 84.2673, 82.5457),
  Time = 0:15,
  Intervention = c(rep(0, 10), rep(1, 6)), 
  TimeAfterIntervention = c(rep(0, 10), 0:5)
)
its_model2 <- lm(Y ~ Time + Intervention + TimeAfterIntervention, data = df2)
summary(its_model2)
# Summary of the model
# Calculate VIF
vif_values2 <- vif(its_model2)
print(vif_values2)
